package Dao;

import domain.Taobao;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import uilts.C3P0utils;

import java.sql.SQLException;
import java.util.List;

public class TaobaoDao {

        C3P0utils c3P0utils=new C3P0utils();
        /*查询所有信息;    单一查询*/
        public List<Taobao> findAll(String sql, List list) throws SQLException {
            QueryRunner queryRunner = new QueryRunner(c3P0utils.getDataSource());
            return queryRunner.query(sql, new BeanListHandler<Taobao>(Taobao.class),list.toArray());

        }

        /*模糊查询*/
        public List<Taobao> mhcx(String sql, String stud) throws SQLException {
            QueryRunner queryRunner = new QueryRunner(c3P0utils.getDataSource());
            return queryRunner.query(sql, new BeanListHandler<Taobao>(Taobao.class),stud);

        }

        /*修改信息*/
        public int update(String sql, List list){
        return c3P0utils.executeUpdate(sql,list.toArray());
        }


        /*删除信息*/

        public int delete(String sql,List list){
            return c3P0utils.executeUpdate(sql,list.toArray());
        }

        /*新增信息*/

    public int xz(String sql,List list) throws SQLException {
        QueryRunner queryRunner = new QueryRunner(c3P0utils.getDataSource());
        return queryRunner.update(sql, list.toArray());

    }



}
